package cn.gson.crm.control.office;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.control.base.BaseServlet;
import cn.gson.crm.model.dao.OfficeDao;
import cn.gson.crm.model.po.OfficePo;
@WebServlet("/office/update")
public class OfficeUpdateServlet extends BaseServlet{
	private OfficeDao officeDao = new OfficeDao();
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String officeId = request.getParameter("oid");
		OfficePo officePo = officeDao.selectOffice(officeId);
		request.setAttribute("officePo", officePo);
		forward("office/office_update.jsp");
	}

	@Override
	protected void post(HttpServletRequest request, HttpServletResponse response) throws Exception {
			String officeId = request.getParameter("id");
			String officeTryMoney = request.getParameter("officeTryMoney");
			String officeFormalMoney = request.getParameter("officeFormalMoney");
			String officeCompany = request.getParameter("officeCompany");
			String officeTime = request.getParameter("officeTime");
			
			officeDao.updateOfiice(officeId, officeCompany, officeTryMoney, officeFormalMoney, officeTime);
			
			forward("../../office/manager");
	}
}
